package com.study.service;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @program: spring
 * @author: jzhou
 * @date: 2022-04-21 21:43
 * @version: 1.0
 * @description: 测试
 **/
public class Test {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(AspectJAppConfig.class);
		UserService userService = (UserService) annotationConfigApplicationContext.getBean("userService");
		userService.test();
		System.out.println(userService);

		//如何找到某个对象上面加了Autowired注解呢
//		UserService userService1 = new UserService();
//		for (Field declaredField : userService1.getClass().getDeclaredFields()) {
//			if (declaredField.isAnnotationPresent(Autowired.class)) {
//				declaredField.setAccessible(true);
//				declaredField.set(userService1,??);
//			}
//		}

//		PostConstruct 注解实现原理
//		for (Method declaredMethod : userService.getClass().getDeclaredMethods()) {
//			if (declaredMethod.isAnnotationPresent(PostConstruct.class)){
//				declaredMethod.invoke(userService,null)
//			}
//		}
	}
}
